package com.hps.activemq.aq;

import com.hps.activemq.entity.Order;
import com.hps.activemq.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author heps
 * @date 2019/1/11 17:41
 */
@Component
public class OrderConsumer {

    private static Logger logger = LoggerFactory.getLogger(OrderConsumer.class);

    private OrderService orderService;

    public OrderConsumer(OrderService orderService) {
        this.orderService = orderService;
    }

    /**
     * 处理消息队列中的订单
     * @param order 从消息队列中获取的消息
     */
    @JmsListener(destination = "order_queue")
    public void receiver(Order order) {
        orderService.dealOrder(order);
    }
}
